#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 crane <crane@crane-pc>
#
# Distributed under terms of the MIT license.

import matplotlib
import matplotlib.pyplot as plt
from math import *
from numpy import arange


plt.gca().set_aspect('equal', adjustable='box')


def plot_x_y_axis(max=200):
    a =  [-max, max]
    b =  [0, 0]

    plt.plot(a, b)     # x
    plt.plot(b, a)     # y

def draw_cycloid(r=1, theta=4*pi):
    '''
        内摆线
    '''
    xs = []
    ys = []

    # l = lambda theta: sin(2*theta)
    for degree in arange(0, theta, 0.01):
        x = degree - sin(degree)
        y = 1 - cos(degree)
        x = r*x
        y = r*y

        xs.append(x)
        ys.append(y)

    plt.plot(xs, ys)
    plot_x_y_axis(r * theta)


    plt.show()


def main():
    print("start main")
    draw_cycloid(theta=6*pi, r=3)

if __name__ == "__main__":
    main()
